package com.lsy.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lsy.entity.AccountAndArticleAndCommentCnd;
import com.lsy.entity.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 项目名：springboot01
 * 包名：com.lsy.dao
 * 类名：CommentMapper
 * 描述：CommentMapper接口
 * 作者：柳胜酉
 * 开始时间：2023/6/11
 * 完成时间：
 * 版本：1.0
 */
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    @Insert("insert into comment (article_id,user_id,comment_content,comment_time,comment_likes) " +
            "values (#{article_id},#{user_id},#{comment_content},#{comment_time},0)")
    void addComments(Comment comment);

    @Select("select * from comment;")
    List<Comment> selectComment();

    @Select("select * from comment where article_id = #{article_id};")
    List<Comment> selectCommentByArticleId(Integer article_id);

    @Delete("delete from comment where comment_id = #{comment_id};")
    int deleteCommentByComment_id(Integer comment_id);

}

